<template>
	<view class="" style="min-height: 100vh;"
		:style="{background:'url('+Imgbase+'/brave_goodpoor_bgc.png)','background-size':'100%',}">
		<view class="zinde">
			<view class="" style="padding: 105rpx 20rpx 0;position: relative;z-index: 99;" @click="back">
				<image class="w-80 h-80 margin-top-10" :src="Imgbase + '/brave_goodindex_img1.png'" mode="aspectFit">
				</image>
			</view>
		</view>

		<view class="padding-30">
			<!-- tab -->
			<view class="df jc-sa alc padding-bottom-30">
				<!-- <view class="w-200 h-90">
					<image class="w100 h100" :src=" Imgbase+'/new_goodorder_tab1' + [TabCur==1?'_c':''] + '.png'"
						mode="aspectFit">
					</image>
				</view> -->
				<view class="w-280 h-130" @click="tab(1)">
					<image class="w100 h100" :src=" Imgbase+'/brave_goodadd_img1' + [TabCur==1?'on':''] + '.png'"
						mode="aspectFit">
					</image>
				</view>
				<view class="w-280 h-130" @click="tab(2)">
					<image class="w100 h100" :src=" Imgbase+'/brave_goodadd_img2' + [TabCur==2?'on':''] + '.png'"
						mode="aspectFit">
					</image>
				</view>

			</view>

			<view class="w-690 margin-auto Afont" style="height: 75vh;">

				<scroll-view scroll-y class="w100 padding-top-10" scroll-with-animation
					style="overflow: hidden;height: 90%;" @scrolltolower="onbottom()">

					<view class="padding">
						<view class="padding-bottom-20" v-if="TabCur==2">
							<u-subsection mode="subsection" :list="falist" :current="curNow" @change="sectionChange"
								fontSize="14" activeColor="#506EB8"></u-subsection>
						</view>

						<view class="padding-40 margin-bottom-25 black-color " v-for="(item,index) in userlist" :key="index"
							:style="{background:'url('+Imgbase+'/brave_goodadd_img3.png)','background-size':'100% 100%',}">
							
							<view class="">
								<scroll-view scroll-x class="nav w100 fff" style="overflow: hidden;">
									<view class="tab_item margin-right-15"
										style="display: inline-block;position: relative;"
										v-for="(it,idx) in item.good_mes" :key="idx">
										<image class="w-100 h-100 radius-15" :src="it.adimage" mode="aspectFit"></image>
										<view class="" v-if="TabCur==2"
											style="position: absolute;right: 5rpx;bottom: 5rpx;z-index: 99;color: #FBBD08;font-weight: bold;">
											x{{it.num}}
										</view>
									</view>
								</scroll-view>
							</view>
							<view class="font-20 w100 padding-top-10">
								<view class="padding-bottom-5 df">
									<view class="w-100">
										快递编号:
									</view>
									<text v-if="TabCur==2">{{item.deliverno}}</text>
									<text v-else>尚未发货</text>
								</view>
								<!-- <view class="">
											<image @click="searchExpress(item.deliverno,item.user_deliver_id)"
												class="w-150 h-60" :src=" Imgbase+'/kp_backp_img4.png'" mode="aspectFit">
											</image>
										</view> -->
								<view class="padding-top-5 padding-bottom-5">
									<view class="">
										<view class="padding-bottom-5">
											<view class="df">
												<view class="w-100">
													收货人：
												</view> {{item.addr_info.name}}
											</view>
											<view class="">
												收货电话：{{item.addr_info.phone}}
											</view>
										</view>
										<view class="df">
											<view class="w-100">
												收货地址：
											</view> {{item.addr_info.detail}}
										</view>
										<view class="df padding-top-5 df jc-sb">
											<view class="">
												下单时间：{{item.createtime_text}}
											</view> 
											
											<view class="padding-top-8 padding-left-15" v-if="TabCur==2">
												<image @click="searchExpress(item.deliverno,item.user_deliver_id)"
													class="w-125 h-45" :src=" Imgbase+'/brave_goodadd_img4.png'" mode="aspectFit">
												</image>
											</view>
										</view>
									</view>
								</view>
								
							</view>
						</view>
					</view>


					<view class="h-50">

					</view>
				</scroll-view>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				Imgbase: getApp().globalData.Imgbase,
				TabCur: 1,
				userlist: [],
				falist: ['正常发货', '随单发货'],
				curNow: 0,
				userpage: 1
			}
		},
		onLoad(e) {
			this.TabCur = e.id
			this.userBag()
		},
		onShow() {
			// this.userlist = []
		},
		methods: {
			// 查看物流
			searchExpress(expressno, id) {
				let _this = this;
				// if(expressno == 0){
				// 	uni.navigateTo({
				// 		url: `/pages/goodspoor/express?expressno=${expressno}&uid=${id}`
				// 	})
				// }

				uni.navigateTo({
					url: `/pages/goodspoor/express?expressno=${expressno}&uid=${id}`
				})
			},
			onbottom() {
				this.userpage++;
				this.userBag();
			},
			sectionChange(index) {
				this.userlist = []
				this.userpage = 1
				this.curNow = index;
				this.userBag()
			},
			tab(e) {
				this.TabCur = e
				this.userlist = []
				this.userBag()
			},
			back() {
				uni.navigateBack()
			},
			async userBag() {
				let _this = this
				let item = await this.$api.post('Usersys/userBag', {
					page: _this.userpage,
					tab: _this.TabCur,
					lock: 0,
					limit: 80,
					token: uni.getStorageSync('token'),
					dui: 0,
					send_type: _this.curNow
				})
				if (item.data.list.length > 0) {
					item.data.list.forEach(function(e, i) {
						item.data.list[i].checked = 0;
						_this.userlist = _this.userlist.concat(item.data.list[i])
					})
					this.$forceUpdate()
				} else {
					this.$refs.uToast.show({
						message: "没有更多了",
						duration: 1000
					})
				}
			},
		},
	}
</script>

<style lang="less" scoped>

</style>